package cn.itmtr.screenshot;

import cn.hutool.log.StaticLog;
import cn.hutool.system.SystemUtil;
import cn.itmtr.screenshot.service.IScreenshotService;
import cn.itmtr.screenshot.service.impl.ScreenshotLinuxServiceImpl;
import cn.itmtr.screenshot.service.impl.ScreenshotWindowsServiceImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ScreenshotApplication {

    public static void main(String[] args) {
        SpringApplication.run(ScreenshotApplication.class, args);
        if (args.length <= 0) {
            StaticLog.error("请输入要识别的网站");
            return;
        }
        String url = args[0];
        String imagePath = args.length > 1 ? args[1] : null;
        IScreenshotService screenshotService = SystemUtil.getOsInfo().isWindows() ?
                new ScreenshotWindowsServiceImpl() : new ScreenshotLinuxServiceImpl();
        screenshotService.screenshot(url, imagePath);
        StaticLog.info("----- end -----");
    }

}
